import axios from "axios";
import type { AxiosResponse, InternalAxiosRequestConfig } from "axios";



const service = axios.create({
    baseURL: "http://121.89.205.189:3000/admin",
    timeout: 60000
});


// 请求拦截器
service.interceptors.request.use((config: InternalAxiosRequestConfig) => {

    // 携带token
    const token = localStorage.getItem("token");
    if (token) {
        config.headers.token = token;
    }
    return config;
})


// 响应拦截器
service.interceptors.response.use((res: AxiosResponse) => {
    // loading.value = false;
    // Loadingstore.endLoading()
    return res;
}, (err) => {
    if (err.response.status === 404) {
        console.log("没有找到");
    }
    // loading.value = false;
    // Loadingstore.endLoading()
})

export default service;